package com.zxl.working.utils;

import java.util.Random;

public class DigitalSplitUtil {
    public static int sum(int a[], int n){
        return (n<1)?0:sum(a,n-1)+a[n-1];
    }

    public static int[] splitInto(int money) {
        Random random = new Random();
        int count=money/49999;
        if(money%49999!=0){
            count++;
        }
        int arrs[]=new int[count];
        int sum=0;
        for(int i=0;i<arrs.length-1;i++){
            int min=((money-sum)/(count-i))+1;
            int j = random.nextInt(49999-min)+1 + min;
            arrs[i]=j;
            sum+=j;
        }
        arrs[arrs.length-1]=money-sum;
        return arrs;
    }
}
